import Route from 'react-router/lib/Route';
import { WeaLocaleProvider, WeaTools } from 'ecCom';
import stores from './stores';
import './style';

import Home from './components/Home';
import GroupList from './components/List';

const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'groupVoting');

const onEnter = (nextState, replace, callback) => {
  window.ssoChecked = false;
  WeaTools.checkSSO('', false).then(() => {
    getLocaleLabel(nextState, replace, callback);
  });
};

const GroupVotingRoute = (
  <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@goebvg`} name="groupVoting" breadcrumbName="群投票" path="groupVoting" onEnter={onEnter} component={Home}>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@xt2277`} name="groupList" breadcrumbName="列表信息" path="groupVotingList" component={GroupList} />
  </Route>
);

module.exports = {
  Route: GroupVotingRoute,
  stores,
};
